import { Tag } from "antd"
import { createColumn } from "./common/CommonTable"
import CommonModalPicker from "./common/CommonModalPicker"
import PropTypes from "prop-types"

const ProcessPicker = ({
  onPick,
  disabled,
  disabledKeys = [],
  multiple = true,
  queryListAction,
  btnText
}) => {

  const columns = [
    {
      key: 'name',
      dataIndex: 'name',
      title: '名称'
    },
    {
      key: 'version',
      dataIndex: 'version',
      title: '当前版本',
      width: 100,
      align: 'center',
      render: (text) => {
        return <Tag color="blue">v{text}</Tag>
      }
    },
    {
      key: 'lastUpdatedBy',
      dataIndex: 'lastUpdatedBy',
      title: '更新人',
      width: 100,
      align: 'center',
    },
    createColumn.time({
      dataIndex: 'lastUpdated',
      title: '更新时间',
      width: 180
    }),
  ]

  return <CommonModalPicker
    btnText={btnText}
    typeName="流程"
    multiple={multiple}
    queryAction={queryListAction}
    columns={columns}
    disabledKeys={disabledKeys}
    disabled={disabled}
    onPick={onPick}
    saveType="row"
  ></CommonModalPicker>
}

ProcessPicker.propTypes = {
  onPick: PropTypes.func,
  disabled: PropTypes.bool,
  disabledKeys: PropTypes.array,
  multiple: PropTypes.bool,
  queryListAction: PropTypes.func,
  btnText: PropTypes.string
}

export default ProcessPicker